<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>js入门</title>
</head>
<body>
<div class="login-box">
    <form>
        <div><label for="">用户名</label><input id="username"/></div>
        <div><label for="">密码</label><input id="password"/></div>
        <div>
            <button type="button" id="btnLogin">登录</button>
        </div>

    </form>

</div>
</body>
<!--/*   编程语言
* *  1. 逻辑计算
*    标签语言
* */
/* 1. 获取元素 ----- 选择器
* 2. 获得元素属性
* 3. 事件绑定
* 4. 逻辑处理
* */-->

<script>

    document.getElementById('btnLogin').onclick = function () {

        var test = 'dd'

        alert(typeof test)

        var username = document.getElementById('username').value;
        var password = document.getElementById('password').value;

        if (username == 'admin' && password == '123456') {
            alert('登录成功');
        } else {
            alert("登录失败");
        }
    }
</script>
</html>